package com.brillilab.service.core.experiments.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.experiments.ExperimentProduceAttrMapper;
import com.brillilab.domain.po.experiments.ExperimentProduce;
import com.brillilab.domain.po.experiments.ExperimentProduceAttr;
import com.brillilab.service.core.experiments.IExperimentProduceAttrService;


@Service
@Transactional
public class ExperimentProduceAttrServiceImpl  implements IExperimentProduceAttrService {

    @Resource
    private ExperimentProduceAttrMapper experimentProduceAttrMapper;

	@Override
	public ExperimentProduceAttr insert(ExperimentProduceAttr attr) {
		experimentProduceAttrMapper.insert(attr);
		return attr;
	}

	@Override
	public List<ExperimentProduceAttr> insertBatch(List<ExperimentProduceAttr> attrList) {
		if(CollectionUtils.isNotEmpty(attrList)) {
			Integer rs = experimentProduceAttrMapper.insertBatch(attrList);
			Assert.isTrue(rs == attrList.size(),"操作失败！");
		}
		return attrList;
	}

	@Override
	public List<ExperimentProduceAttr> selectList(Long produceId) {
		return experimentProduceAttrMapper.selectList(
				new LambdaQueryWrapper<ExperimentProduceAttr>()
						.eq(ExperimentProduceAttr::getProduceId,produceId));
	}
}
